package com.woniuxy.intellihome.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniuxy.intellihome.entity.GoodsSpecDetail;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author jobob
 * @since 2021-08-11
 */
public interface GoodsSpecDetailMapper extends BaseMapper<GoodsSpecDetail> {
    @Select("select sku_id from m_goods_spec_detail where spec_detail_id =#{id1} \n" +
            " and sku_id in (select sku_id from m_goods_spec_detail where spec_detail_id=#{id2})")
    Integer getSpecIdBySpecValueId2(@Param("id1") int id1, @Param("id2") int id2);

    @Select("select sku_id from m_goods_spec_detail where spec_detail_id =#{id1} \n" +
            " and sku_id in (select sku_id from m_goods_spec_detail where spec_detail_id=#{id2})\n" +
            " and sku_id in (select sku_id from m_goods_spec_detail where spec_detail_id=#{id3})")
    Integer getSpecIdBySpecValueId3(@Param("id1") int id1, @Param("id2") int id2, @Param("id3") int id3);

    @Select("select sku_id from m_goods_spec_detail where spec_detail_id =#{id1} \n" +
            " and sku_id in (select sku_id from m_goods_spec_detail where spec_detail_id=#{id2})\n" +
            " and sku_id in (select sku_id from m_goods_spec_detail where spec_detail_id=#{id3}) \n" +
            " and sku_id in (select sku_id from m_goods_spec_detail where spec_detail_id=#{id4})")
    Integer getSpecIdBySpecValueId4(@Param("id1") int id1, @Param("id2") int id2, @Param("id3") int id3, @Param("id4") int id4);

    @Select(" select sku_id from m_goods_spec_detail where spec_detail_id =#{id1} \n" +
            " and sku_id in (select sku_id from m_goods_spec_detail where spec_detail_id=#{id2})\n" +
            " and sku_id in (select sku_id from m_goods_spec_detail where spec_detail_id=#{id3}) \n" +
            " and sku_id in (select sku_id from m_goods_spec_detail where spec_detail_id=#{id4})\n" +
            " and sku_id in (select sku_id from m_goods_spec_detail where spec_detail_id=#{id5})")
    Integer getSpecIdBySpecValueId5(@Param("id1") int id1, @Param("id2") int id2, @Param("id3") int id3, @Param("id4") int id4, @Param("id5") int id5);

    @Select("select sku_id from m_goods_spec_detail where goods_id =#{goods_id}")
    List<Integer> getSkuIdBySpuId(int goods_id);
}

